<!DOCTYPE HTML>{{$page := .}}
<html lang="zh" class="sidebar-visible no-js light">
    <head>
        <!-- Book generated using https://github.com/wa-lang/mnbook -->
        <meta charset="UTF-8">
        <title>{{$page.Title}}</title>
        <!-- Custom HTML head -->
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="theme-color" content="#ffffff" />

        <link rel="icon" href="{{$page.Root}}/favicon.svg">
        <link rel="shortcut icon" href="{{$page.Root}}/favicon.png">
        <link rel="stylesheet" href="{{$page.Root}}/static/mnbook/css/variables.css">
        <link rel="stylesheet" href="{{$page.Root}}/static/mnbook/css/general.css">
        <link rel="stylesheet" href="{{$page.Root}}/static/mnbook/css/chrome.css">
        <link rel="stylesheet" href="{{$page.Root}}/static/mnbook/css/print.css" media="print">
        <!-- Fonts -->
        <link rel="stylesheet" href="{{$page.Root}}/static/mnbook/FontAwesome/css/font-awesome.css">
        <link rel="stylesheet" href="{{$page.Root}}/static/mnbook/fonts/fonts.css">
        <!-- Highlight.js Stylesheets -->
        <link rel="stylesheet" href="{{$page.Root}}/static/mnbook/highlight.css">
        <link rel="stylesheet" href="{{$page.Root}}/static/mnbook/tomorrow-night.css">
        <link rel="stylesheet" href="{{$page.Root}}/static/mnbook/ayu-highlight.css">

        <!-- Custom theme stylesheets -->
    </head>
    <body>
        <!-- Provide site root to javascript -->
        <script type="text/javascript">
            var path_to_root = "{{$page.Root}}/";
            var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "navy" : "light";
        </script>

        <!-- Work around some values being stored in localStorage wrapped in quotes -->
        <script type="text/javascript">
            try {
                var theme = localStorage.getItem('mnbook-theme');
                var sidebar = localStorage.getItem('mnbook-sidebar');

                if (theme.startsWith('"') && theme.endsWith('"')) {
                    localStorage.setItem('mnbook-theme', theme.slice(1, theme.length - 1));
                }

                if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
                    localStorage.setItem('mnbook-sidebar', sidebar.slice(1, sidebar.length - 1));
                }
            } catch (e) { }
        </script>

        <!-- Set the theme before any content is loaded, prevents flash -->
        <script type="text/javascript">
            var theme;
            try { theme = localStorage.getItem('mnbook-theme'); } catch(e) { }
            if (theme === null || theme === undefined) { theme = default_theme; }
            var html = document.querySelector('html');
            html.classList.remove('no-js')
            html.classList.remove('light')
            html.classList.add(theme);
            html.classList.add('js');
        </script>

        <!-- Hide / unhide sidebar before it is displayed -->
        <script type="text/javascript">
            var html = document.querySelector('html');
            var sidebar = 'hidden';
            if (document.body.clientWidth >= 1080) {
                try { sidebar = localStorage.getItem('mnbook-sidebar'); } catch(e) { }
                sidebar = sidebar || 'visible';
            }
            html.classList.remove('sidebar-visible');
            html.classList.add("sidebar-" + sidebar);
        </script>

        <nav id="sidebar" class="sidebar" aria-label="Table of contents">
            <div class="sidebar-scrollbox">
                {{genSidebarItems $page.Root $page.Index}}
            </div>
            <div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
        </nav>

        <div id="page-wrapper" class="page-wrapper">

            <div class="page">
                <div id="menu-bar-hover-placeholder"></div>
                <div id="menu-bar" class="menu-bar sticky bordered">
                    <div class="left-buttons">
                        <button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
                            <i class="fa fa-bars"></i>
                        </button>
                        <button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
                            <i class="fa fa-paint-brush"></i>
                        </button>
                        <ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
                            <li role="none"><button role="menuitem" class="theme" id="light">Light (default)</button></li>
                            <li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
                            <li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
                            <li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
                        </ul>
                    </div>

                    <h1 class="menu-title"><a href="{{$page.Root}}/index.html">{{$page.Book.Title}}</a></h1>

                    <div class="right-buttons">
                        <a href="{{$page.Book.GitRepoUrl}}" title="Git repository" aria-label="Git repository">
                            <i id="git-repository-button" class="fa {{$page.Book.GitRepoIcon}}"></i>
                        </a>
                        <a href="{{$page.EditUrlTemplate}}" title="Suggest an edit" aria-label="Suggest an edit">
                            <i id="git-edit-button" class="fa fa-edit"></i>
                        </a>
                    </div>
                </div>

                <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
                <script type="text/javascript">
                    document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
                    document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
                    Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
                        link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
                    });
                </script>

                <div id="content" class="content">
                    <main>
                        {{$page.RawHtml}}
                    </main>

                    <nav class="nav-wrapper" aria-label="Page navigation">
                        <!-- Mobile navigation buttons -->
                        {{if $page.HasPrev}}
                            <a rel="prev" href="{{$page.Root}}/{{$page.PrevUrl}}" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
                                <i class="fa fa-angle-left"></i>
                            </a>
                        {{end}}
                        {{if $page.HasNext}}
                            <!-- {{$page.Root}}/{{$page.NextUrl}} -->
                            <a rel="next" href="{{$page.Root}}/{{$page.NextUrl}}" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
                                <i class="fa fa-angle-right"></i>
                            </a>
                        {{end}}
                        <div style="clear: both"></div>
                    </nav>
                </div>
            </div>

            <nav class="nav-wide-wrapper" aria-label="Page navigation">
                {{if $page.HasPrev}}
                    <a rel="prev" href="{{$page.Root}}/{{$page.PrevUrl}}" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
                        <i class="fa fa-angle-left"></i>
                    </a>
                {{end}}
                {{if $page.HasNext}}
                    <a rel="next" href="{{$page.Root}}/{{$page.NextUrl}}" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
                        <i class="fa fa-angle-right"></i>
                    </a>
                {{end}}
            </nav>

        </div>

        <script type="text/javascript">
            window.playground_copyable = true;
        </script>
        <script src="{{$page.Root}}/static/mnbook/mark.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="{{$page.Root}}/static/mnbook/clipboard.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="{{$page.Root}}/static/mnbook/highlight.js" type="text/javascript" charset="utf-8"></script>
        <script src="{{$page.Root}}/static/mnbook/book.js" type="text/javascript" charset="utf-8"></script>

        <!-- Custom JS scripts -->
    </body>
</html>
